/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListRendererCargos.java
 *
 * Created on 10/04/2011, 03:14:35 PM
 */

package frontera.interfaz.listRenderer;

import entidad.Cargo;
import java.awt.Color;
import java.awt.Component;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author Sebastian
 */
public class ListRendererCargos extends javax.swing.JPanel implements ListCellRenderer {

    /** Creates new form ListRendererCargos */
    public ListRendererCargos() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelNombre = new javax.swing.JLabel();
        labelDepartamento = new javax.swing.JLabel();
        labelSalarioBasico = new javax.swing.JLabel();

        setLayout(new java.awt.GridLayout());

        labelNombre.setText("jLabel1");
        add(labelNombre);

        labelDepartamento.setText("jLabel2");
        add(labelDepartamento);

        labelSalarioBasico.setText("jLabel3");
        add(labelSalarioBasico);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel labelDepartamento;
    private javax.swing.JLabel labelNombre;
    private javax.swing.JLabel labelSalarioBasico;
    // End of variables declaration//GEN-END:variables

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Cargo cargo = (Cargo)value;

            labelNombre.setText(cargo.getNombre());
            labelDepartamento.setText(cargo.getDepartamento().getNombre());
            labelSalarioBasico.setText(cargo.getSalarioBásico());

            if(isSelected){
                this.setBackground(new Color(200, 200, 255));
            }
            else{
                this.setBackground(new Color(255, 255, 255));
            }

            return this;
    }



}
